{include file="public/head"}

<body>
<div id="wrapper">

    <div class="gray-bg dashbard-1">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                            <div class="form-horizontal m-t">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">公告标题：</label>
                                    <div class="col-sm-8">
                                        <input id="title" name="title" maxlength="255" type="text" class="form-control" required="" aria-required="true" value="{$NoticeInfo.title}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">公告排序：</label>
                                    <div class="col-sm-8">
                                        <input id="sort" name="sort" type="text" class="form-control"  required="" aria-required="true" value="{$NoticeInfo.sort}" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-3 control-label">公告内容：</label>
                                    <div class="col-sm-8">
                                        <script id="content" type="text/plain" style="width:100%;height:400px;">{$NoticeInfo.content}</script>
                                    </div>
                                </div>

                                <input type="hidden" id="id" value="{$NoticeInfo.id}"/>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-3">
                                        <button class="btn btn-primary" type="button" id="sub">保存并发布</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>
<script src="__STATIC__/Admin/js/jquery-2.1.1.min.js"></script>
<script src="__STATIC__/Admin/js/bootstrap.min.js?v=3.4.0"></script>
<script src="__STATIC__/Admin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__STATIC__/Admin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/Admin/layer/layer.js"></script>
<script src="__STATIC__/Admin/ueditor/1.4.3/ueditor.config.js"></script>
<script src="__STATIC__/Admin/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script src="__STATIC__/Admin/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script>
    var editor = new UE.ui.Editor();
    editor.render("content");

    $("#sub").on('click',function(){
        var title = $('#title').val();
        var sort = $('#sort').val();
        var content = editor.getContent();

        if(title == ''){
            layer.msg('请输入公告标题',{icon: 5,time:2000});
            return false;
        }

        if(sort == ''){
            layer.msg('请输入公告排序',{icon: 5,time:2000});
            return false;
        }

        if(content == ''){
            layer.msg('请输入公告内容',{icon: 5,time:2000});
            return false;
        }

        $.ajax({
            type:"POST",
            url:"{:url('Notice/NoticeEdit')}",
            data:{
                id:$('#id').val(),
                title:title,
                sort:sort,
                content:content,
            },
            dataType:"json",
            success:function(data){
                if(data.status == 1){
                    layer.msg(data.message, {icon: 6,time:1500},function () {
                        window.top.location.reload();
                    });
                }else{
                    layer.msg(data.message,{icon: 5,time:1000});
                }
            }
        });
    })
</script>
</body>

</html>
